function fn(n) {

    if(n==3)
     {
           document.getElementById("img1").style.display="none";
         document.getElementById("img2").style.display="none";
      document.getElementById("img3").style.display="block";
     }
        
    if(n==2)
    {
    nextn=n+1;
    document.getElementById("img1").style.display="none";
    document.getElementById("img3").style.display="none";
    document.getElementById("img2").style.display="block";
}

   if(n==1)
    { 
        document.getElementById("img2").style.display="none";
          document.getElementById("img3").style.display="none";
        document.getElementById("img1").style.display="block";}
   
 
}


window.onload=init;

var n=1; //图片标记数

var dingshi; //让图片动的定时器

function init(){
dingshi=window.setInterval("tupian()",2500);
}
//更换图片
function tupian(){
var obj=document.getElementById("img1");
n++;

if(n>=3){
n=1;
}
obj.src="./images/p" + n+".jpg";
}
//鼠标放上图片停止
function stoptupian(){
window.clearInterval(dingshi);
}
//鼠标离开图片动起来
function dongqilai(){
dingshi=window.setInterval("tupian()",2500);
}
